﻿#include "mfs_car_object.h"


mFS_car_object::mFS_car_object(mFS_car_object *parent)
    : MBaseObject (parent)
{
    this->setZValue(-5);
    CarNumberItem = new QGraphicsTextItem("FS***" , this);
    QFont font = CarNumberItem->font();
    font.setBold(true);
    font.setFamily("Times New Roman");
    CarNumberItem->setFont(font);
    CarNumberItem->setPos(-4,75);
    CarNumberItem->setRotation(-90);

    socketBLeft = new SocketObject(this,CarNumberItem,getCarIP());
    socketBLeft->SocketID("KBL");
    socketBLeft->socketNumber("3");
    socketBLeft->setPos(115, 70);

    socketBright = new SocketObject(this,CarNumberItem,getCarIP());
    socketBright->SocketID("KBR");
    socketBright->socketNumber("6");
    socketBright->setPos(115, 25);
}

mFS_car_object::~mFS_car_object()
{

}

QRectF mFS_car_object::boundingRect() const
{
    return QRectF(0,0,140,90);
}

void mFS_car_object::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    Q_UNUSED(option); Q_UNUSED(widget);

    //车的外观
    QRectF squareRect_head = QRectF(0,15,20,60);
    QRectF squareRect_back = QRectF(20,0,120,90);
    QPen pen(QColor(237, 125, 49), 2, Qt::SolidLine);
    painter->setPen(pen);
    painter->drawRect(squareRect_head);
    painter->drawRect(squareRect_back);

    if(this->isSelected())
        drawSelectedRect(painter);
}
